
# This file is part of the LITIV framework; visit the original repository at
# https://github.com/plstcharles/litiv for more information.
#
# Copyright 2016 Pierre-Luc St-Charles; pierre-luc.st-charles<at>polymtl.ca
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ---------------------------------------------------------------------------
#
#                LITIV Framework CMake Configuration File
#   (this file is generated automatically, any modification will be lost)
#
#  To use in an external project, add these lines to your 'CMakeLists.txt' file:
#
#      find_package(litiv REQUIRED)
#      include_directories(${LITIV_EXT_INCLUDE_DIRS}) # not needed if external headers can already be located by the toolchain
#      target_link_libraries(<YOUR_TARGET_NAME> litiv_world) # ...or a more specific submodule/target of the framework, as needed
#
#  ...and set 'litiv_DIR' during configuration to the LITIV build output or installation directory. If one or more required external
#  dependency cannot be found, the 'find_package(litiv ...)' call will fail, and print some information on the missing component.
#
#  This file will define the following variables (where * = marked as advanced):
#    * LITIV_RUNTIME_DIRS         : Directory(ies) where executables and DLLs are located; typically not needed by CMake projects
#    * LITIV_INCLUDE_DIRS         : Directory(ies) where headers are located; typically not needed by CMake projects
#    * LITIV_LIBRARY_DIRS         : Directory(ies) where libraries are located; typically not needed by CMake projects
#    * LITIV_MODULES_DIRS         : Directory(ies) where cmake modules are located; automatically added to CMAKE_MODULE_PATH
#    * LITIV_CONFIG_DIRS          : Directory(ies) where config/model files; typically not needed by CMake projects
#      LITIV_EXT_INCLUDE_DIRS     : Directories where headers for external dependencies are located
#    * LITIV_COMPONENTS           : List of all built framework components which can be used externally
#    * LITIV_VERSION              : Dot-separated version number of this LITIV build ("@LITIV_VERSION@")
#    * LITIV_VERSION_MAJOR        : Major version part of LITIV_VERSION (@LITIV_VERSION_MAJOR@)
#    * LITIV_VERSION_MINOR        : Minor version part of LITIV_VERSION (@LITIV_VERSION_MINOR@)
#    * LITIV_VERSION_PATCH        : Patch version part of LITIV_VERSION (@LITIV_VERSION_PATCH@)
#    * LITIV_VERSION_SHA1         : Git SHA1 of the HEAD commit of this LITIV build
#    * LITIV_CUDA_VERSION         : CUDA version used by the framework, likely imported from OpenCV
#    * LITIV_SHARED               : Defines whether the LITIV framework modules are built as shared libraries or not
#    * LITIV_INSTALLED            : Defines whether this script is located alongside the install or build directory
#
# ---------------------------------------------------------------------------

cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)

set(LITIV_VERSION "@LITIV_VERSION@")
set(LITIV_VERSION_MAJOR @LITIV_VERSION_MAJOR@)
set(LITIV_VERSION_MINOR @LITIV_VERSION_MINOR@)
set(LITIV_VERSION_PATCH @LITIV_VERSION_PATCH@)
set(LITIV_VERSION_SHA1 "@GIT_SHA1@")
set(LITIV_SHARED @BUILD_SHARED_LIBS@)
set(LITIV_INSTALLED @CURRENT_CONFIG_INSTALL@)
@PACKAGE_INIT@
if(LITIV_INSTALLED)
    set_and_check(LITIV_RUNTIME_DIRS "@PACKAGE_RUNTIME_INSTALL_DIR@")
    set_and_check(LITIV_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@")
    set_and_check(LITIV_LIBRARY_DIRS "@PACKAGE_LIBRARY_INSTALL_DIR@")
    set_and_check(LITIV_MODULES_DIRS "@PACKAGE_MODULES_INSTALL_DIR@")
    #set_and_check(LITIV_CONFIG_DIRS "@PACKAGE_CONFIG_INSTALL_DIR@")
else()
    set(LITIV_RUNTIME_DIRS "@LITIV_BUILD_RUNTIME_DIR@")
    set(LITIV_INCLUDE_DIRS "@LITIV_BUILD_INCLUDE_DIRS@")
    set(LITIV_LIBRARY_DIRS "@LITIV_BUILD_LIBRARY_DIR@")
    set(LITIV_MODULES_DIRS "@LITIV_BUILD_MODULES_DIR@")
    #set(LITIV_CONFIG_DIRS "@LITIV_BUILD_CONFIG_DIR@")
endif()
list(APPEND CMAKE_MODULE_PATH "${LITIV_MODULES_DIRS}")
set(LITIV_COMPONENTS "@LITIV_COMPONENTS@")

include(CMakeFindDependencyMacro)
set(LITIV_EXT_INCLUDE_DIRS "")
message(STATUS "LITIV Framework searching for OpenCV >=3.0 dependency...")
find_dependency(OpenCV 3.0)
if(@USE_GLSL@)
    message(STATUS "LITIV Framework searching for OpenGL dependencies...")
    find_dependency(OpenGL)
    list(APPEND LITIV_EXT_INCLUDE_DIRS "${OpenGL_INCLUDE_DIRS}")
    find_dependency(GLEW)
    list(APPEND LITIV_EXT_INCLUDE_DIRS "${GLEW_INCLUDE_DIRS}")
    find_dependency(GLM)
    list(APPEND LITIV_EXT_INCLUDE_DIRS "${GLM_INCLUDE_DIRS}")
    if(@USE_GLFW@)
        find_dependency(GLFW)
        list(APPEND LITIV_EXT_INCLUDE_DIRS "${GLFW_INCLUDE_DIR}")
    elseif(@USE_FREEGLUT@)
        find_dependency(FREEGLUT)
        list(APPEND LITIV_EXT_INCLUDE_DIRS "${FREEGLUT_INCLUDE_DIR}")
    endif()
endif()
if(@USE_BOOST@)
    message(STATUS "LITIV Framework searching for Boost dependency...")
    find_package(Boost REQUIRED COMPONENTS chrono date_time system filesystem program_options regex serialization) # not using find_dependency due to component here
    list(APPEND LITIV_EXT_INCLUDE_DIRS "${Boost_INCLUDE_DIRS}")
endif()
if(@USE_OPENGM@)
    message(STATUS "LITIV Framework searching for OpenGM dependency with external lib...")
    find_package(OpenGM REQUIRED COMPONENTS ext) # not using find_dependency due to component here
    list(APPEND LITIV_EXT_INCLUDE_DIRS "${OpenGM_INCLUDE_DIRS}")
endif()
if(@USE_CUDA@)
    set(LITIV_CUDA_VERSION "@OpenCV_CUDA_VERSION@")
    find_dependency(CUDA ${LITIV_CUDA_VERSION})
    list(APPEND LITIV_EXT_INCLUDE_DIRS "${CUDA_INCLUDE_DIRS}")
endif()
if(WIN32)
    if(@USE_KINECTSDK@)
        message(STATUS "LITIV Framework searching for KinectSDK2 dependency...")
        find_dependency(KinectSDK2)
        list(APPEND LITIV_EXT_INCLUDE_DIRS "${KinectSDK2_INCLUDE_DIRS}")
    endif()
endif()

include("${CMAKE_CURRENT_LIST_DIR}/litiv-targets.cmake")

if(LITIV_INSTALLED)
    check_required_components(litiv)
endif()

mark_as_advanced(
    LITIV_RUNTIME_DIRS
    LITIV_INCLUDE_DIRS
    LITIV_LIBRARY_DIRS
    LITIV_MODULES_DIRS
    #LITIV_CONFIG_DIRS
    LITIV_COMPONENTS
    LITIV_VERSION
    LITIV_VERSION_MAJOR
    LITIV_VERSION_MINOR
    LITIV_VERSION_PATCH
    LITIV_VERSION_SHA1
    LITIV_SHARED
    LITIV_INSTALLED
)